#ifndef CLASS_IP_RULE_H
#define CLASS_IP_RULE_H
#include <pcap.h>
#include <string.h>
#include <stdlib.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <net/ethernet.h>
#include <QObject>
#include "diffie_hellman.h"
#include "aes_gcm.h"
//typedef struct{
//    unsigned char client_ip[16];
//    unsigned char server_ip[16];
//    pcap_t *p;
//}ip_rule;

//struct psd_header{
//    unsigned int saddr;
//    unsigned int daddr;
//    char mbz;
//    char ptcl;
//    unsigned short tcpl;
//};

//void processPacket(u_char *arg, const struct pcap_pkthdr* pkthdr, const u_char * packet);

//void set_psdheader(struct psd_header* ph, struct iphdr *ip, uint16_t tl);//设置报文头

class class_ip_rule : public QObject
{
public:
    class_ip_rule();

    int cap_start(char *addr[]);
    void processPacket(u_char *arg, const struct pcap_pkthdr* pkthdr, const u_char * packet);
    void set_psdheader(struct psd_header* ph,struct iphdr *ip, uint16_t tl);
    uint16_t calc_cksm(void *pkt, int len);
    diffie_hellman DH1;//client-middle
    diffie_hellman DH2;//middle-server
    aes_gcm aesg1;//client-middle
    aes_gcm aesg2;//middle-server
    unsigned char* getkey(int k);

signals:
    void sendValue(QString qstr1);//这里改参数传值

//public slots:
//    void getValue(QString);//这两句复制到接受方的QT类里


//QObject::connect(class_ip_rule *handle,SIGNAL(sendValue(int)),this,SLOT(getValue(int)));//这句放在调用处

};
#endif // CLASS_IP_RULE_H
